package com.fr.chicken.controller;

import com.fr.chicken.annotation.Verification;
import com.fr.chicken.facade.base.BaseResponseDTO;
import com.fr.chicken.facade.request.GetPrivateMessageListRequsetDTO;
import com.fr.chicken.facade.request.SendSystemMessageRequsetDTO;
import com.fr.chicken.facade.request.SetIsReadRequsetDTO;
import com.fr.chicken.facade.response.GetFriendApplyListResponseDTO;
import com.fr.chicken.facade.response.GetGiveLogResponseDTO;
import com.fr.chicken.facade.response.GetMessageListResponseDTO;
import com.fr.chicken.facade.response.GetPrivateMessageListResponseDTO;
import com.fr.chicken.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/message")
@Api(value = "/api-message", description = "消息管理")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @Verification
    @ApiOperation(value = "发送系统公告", notes = "发送系统公告")
    @RequestMapping(value = "/sendSystemMessage", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO sendSystemMessage(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) SendSystemMessageRequsetDTO requset) {
        BaseResponseDTO response = messageService.sendSystemMessage(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "删除系统公告", notes = "删除系统公告")
    @RequestMapping(value = "/deleteMessageById/{id}", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO deleteMessageById(@RequestHeader String accessToken, @PathVariable(value = "id") @ApiParam(required = true, value = "id") Integer id) {
        BaseResponseDTO response = messageService.deleteMessageById(id);
        return response;
    }

    @Verification
    @ApiOperation(value = "查询赠送记录", notes = "查询赠送记录")
    @RequestMapping(value = "/getGiveLog/{playerId}", method = RequestMethod.GET, produces = "application/json")
    public GetGiveLogResponseDTO getGiveLog(@RequestHeader String accessToken, @PathVariable(value = "playerId") @ApiParam(required = true, value = "用户id") Long playerId) {
        GetGiveLogResponseDTO response = messageService.getGiveLog(playerId);
        return response;
    }

    @Verification
    @ApiOperation(value = "查询与好友的私聊记录", notes = "查询与好友的私聊记录")
    @RequestMapping(value = "/getPrivateMessageList", method = RequestMethod.GET, produces = "application/json")
    public GetPrivateMessageListResponseDTO getPrivateMessageList(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) GetPrivateMessageListRequsetDTO requset) {
        GetPrivateMessageListResponseDTO response = messageService.getPrivateMessageList(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "查询消息列表", notes = "查询消息列表")
    @RequestMapping(value = "/getMessageList/{playerId}", method = RequestMethod.GET, produces = "application/json")
    public GetMessageListResponseDTO getMessageList(@RequestHeader String accessToken, @PathVariable(value = "playerId") @ApiParam(required = true, value = "用户id") Long playerId) {
        GetMessageListResponseDTO response = messageService.getMessageList(playerId);
        return response;
    }

    @Verification
    @ApiOperation(value = "好友申请列表", notes = "好友申请列表")
    @RequestMapping(value = "/getFriendApplyList/{playerId}", method = RequestMethod.GET, produces = "application/json")
    public GetFriendApplyListResponseDTO getFriendApplyList(@RequestHeader String accessToken, @PathVariable(value = "playerId") @ApiParam(required = true, value = "用户id") Long playerId) {
        GetFriendApplyListResponseDTO response = messageService.getFriendApplyList(playerId);
        return response;
    }

    @Verification
    @ApiOperation(value = "将消息设为已读", notes = "将消息设为已读")
    @RequestMapping(value = "/setIsRead", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO setIsRead(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) SetIsReadRequsetDTO requset) {
        BaseResponseDTO response = messageService.setIsRead(requset);
        return response;
    }
}
